﻿using System;

namespace KuiHuaBaoDian.Services.Timer {

    /// <summary>
    /// 计时器句柄
    /// </summary>
    public readonly struct TimerHandle {

        /// <summary>
        /// 空值
        /// </summary>
        public static readonly TimerHandle None = new();

        /// <summary>
        /// GUID
        /// </summary>
        public Guid GUID { get; init; }

        public override readonly string ToString() => $"[{nameof(TimerHandle)}({GUID})]";

        public override readonly int GetHashCode() => GUID.GetHashCode();

        public override bool Equals(object obj) {
            if (obj is TimerHandle other) {
                return other.GUID == GUID;
            }
            return false;
        }

        public static bool operator ==(TimerHandle left, TimerHandle right) => left.Equals(right);
        public static bool operator !=(TimerHandle left, TimerHandle right) => !left.Equals(right);
    }
}
